package com.app.mingluxing.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.app.mingluxing.R;
import com.app.mingluxing.bean.GroupSettingBean;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import java.util.ArrayList;

/**
 * 删除群成员的 横向的recycleview的 adapter
 * Created by Aaron on 16/2/25.
 */
public class RemoveNumsRecyAdapter extends RecyclerView.Adapter<RemoveNumsRecyAdapter.RemoveNumsViewHolder> {

   private ArrayList<GroupSettingBean.TopicEntity.UserListEntity> removeList;
    private Context ctx;
    private LayoutInflater mLayoutInflater;

    public RemoveNumsRecyAdapter(Context ctx, ArrayList<GroupSettingBean.TopicEntity.UserListEntity> removeList) {
        this.ctx = ctx;
        this.mLayoutInflater = LayoutInflater.from(ctx);
        this.removeList = removeList;
    }

    @Override
    public int getItemCount() {
        return removeList.size();
    }

    @Override
    public RemoveNumsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new RemoveNumsViewHolder(mLayoutInflater.inflate(R.layout.item_choose_nums_recycler,parent, false));
    }

    @Override
    public void onBindViewHolder(RemoveNumsViewHolder holder, int position) {

        if (removeList==null || removeList.get(position) == null || removeList.get(position).user == null) {
            return;
        }

        Glide.with(ctx)
                .load(removeList.get(position).user.imgUrl)
                .dontAnimate().diskCacheStrategy(DiskCacheStrategy.SOURCE).fitCenter()
                .placeholder(R.mipmap.temp_pic).into(holder.iv_pic);//聊天头像

    }

    //自定义的ViewHolder，持有每个Item的的所有界面元素
    public static class RemoveNumsViewHolder extends RecyclerView.ViewHolder {

        ImageView iv_pic;

        RemoveNumsViewHolder(View view) {
            super(view);

            iv_pic = (ImageView) view.findViewById(R.id.iv_pic);

        }
    }

}